import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'


export const constantRoutes = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  // 首页
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '后台管理系统', icon: 'dashboard' }
    }]
  }]
/**
 * 动态路由
 */
export const asyncRoutes = [

  // 讲师管理
  {
    path: '/teacher',
    component: Layout,
    redirect: '/teacher/table',
    name: '讲师管理',
    meta: { title: '讲师管理', icon: 'example' },
    children: [
      {
        path: 'table',
        name: '讲师列表',
        component: () => import('@/views/cms/teacher/list'),
        meta: { title: '讲师列表', icon: 'table' }
      },
      {
        path: 'save',
        name: '添加讲师',
        component: () => import('@/views/cms/teacher/save'),
        meta: { title: '添加讲师', icon: 'tree' }
      },
      {
        path: 'edit/:id',
        name: 'eduTeacherEdit',
        component: () => import('@/views/cms/teacher/save'),
        meta: { title: '编辑讲师', noCache: true },
        hidden: true
      }
    ]
  },
  // 课程分类
  {
    path: '/subject',
    component: Layout,
    redirect: '/subject/list',
    name: '课程分类管理',
    meta: { title: '课程分类管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '课程分类列表',
        component: () => import('@/views/cms/subject/list'),
        meta: { title: '课程分类列表', icon: 'table' }
      },
      {
        path: 'save',
        name: '添加课程分类',
        component: () => import('@/views/cms/subject/save'),
        meta: { title: '添加课程分类', icon: 'tree' }
      }
    ]
  },
  // 班级管理
  {
    path: '/classes',
    component: Layout,
    redirect: '/teacher/table',
    name: '班级管理',
    meta: { title: '班级管理', icon: 'example' },
    children: [
      {
        path: 'table',
        name: '班级列表',
        component: () => import('@/views/cms/classes/list'),
        meta: { title: '班级列表', icon: 'table' }
      },
      {
        path: 'save',
        name: '添加班级',
        component: () => import('@/views/cms/classes/save'),
        meta: { title: '添加班级', icon: 'tree' }
      },
      {
        path: 'edit/:id',
        name: 'classEdit',
        component: () => import('@/views/cms/classes/save'),
        meta: { title: '编辑班级信息', noCache: true },
        hidden: true
      }
    ]
  },
  // 学生管理
  {
    path: '/students',
    component: Layout,
    redirect: '/students/table',
    name: '学生管理',
    meta: { title: '学生管理', icon: 'example' },
    children: [
      {
        path: 'table',
        name: '学生列表',
        component: () => import('@/views/cms/students/list'),
        meta: { title: '学生列表', icon: 'table' }
      },
      {
        path: 'save',
        name: '添加学生',
        component: () => import('@/views/cms/students/save'),
        meta: { title: '添加学生', icon: 'tree' }
      },
      {
        path: 'edit/:id',
        name: 'studentEdit',
        component: () => import('@/views/cms/students/save'),
        meta: { title: '编辑学生信息', noCache: true },
        hidden: true
      }
    ]
  },
  // 学期管理
  {
    path: '/semesters',
    component: Layout,
    redirect: '/semesters/table',
    name: '学期管理',
    meta: { title: '学期管理', icon: 'example' },
    children: [
      {
        path: 'table',
        name: '学期列表',
        component: () => import('@/views/cms/semesters/list'),
        meta: { title: '学期列表', icon: 'table' }
      },
      {
        path: 'save',
        name: '添加学期',
        component: () => import('@/views/cms/semesters/save'),
        meta: { title: '添加学期', icon: 'tree' }
      },
      {
        path: 'edit/:id',
        name: 'SemesterEdit',
        component: () => import('@/views/cms/semesters/save'),
        meta: { title: '编辑学期信息', noCache: true },
        hidden: true
      }
    ]
  },
  // 课程管理
  {
    path: '/courses',
    component: Layout,
    redirect: '/courses/table',
    name: '课程管理',
    meta: { title: '课程管理', icon: 'example' },
    children: [
      {
        path: 'table',
        name: '课程列表',
        component: () => import('@/views/cms/courses/list'),
        meta: { title: '课程列表', icon: 'table' }
      },
      {
        path: 'save',
        name: '添加课程',
        component: () => import('@/views/cms/courses/save'),
        meta: { title: '添加课程', icon: 'tree' }
      },
      {
        path: 'edit/:id',
        name: '修改课程',
        component: () => import('@/views/cms/courses/save'),
        meta: { title: '编辑课程信息', noCache: true },
        hidden: true
      }
    ]
  },
  // 考试管理
  {
    path: '/exams',
    component: Layout,
    redirect: '/exams/table',
    name: '考试管理',
    meta: { title: '考试管理', icon: 'example' },
    children: [
      {
        path: 'table',
        name: '考试列表',
        component: () => import('@/views/cms/exams/list'),
        meta: { title: '考试列表', icon: 'table' }
      },
      {
        path: 'save',
        name: '添加考试',
        component: () => import('@/views/cms/exams/save'),
        meta: { title: '添加考试', icon: 'tree' }
      },
      {
        path: 'edit/:id',
        name: '修改考试',
        component: () => import('@/views/cms/exams/save'),
        meta: { title: '编辑考试信息', noCache: true },
        hidden: true
      }
    ]
  },
  // 考试成绩管理
  {
    path: '/examsScores',
    component: Layout,
    redirect: '/examsScores/table',
    name: '考试成绩管理',
    meta: { title: '考试成绩管理', icon: 'example' },
    children: [
      {
        path: 'table',
        name: '成绩列表',
        component: () => import('@/views/cms/examsScores/list'),
        meta: { title: '成绩列表', icon: 'table' }
      },
      {
        path: 'save',
        name: '添加成绩',
        component: () => import('@/views/cms/examsScores/save'),
        meta: { title: '添加成绩', icon: 'tree' }
      },
      {
        path: 'statistics',
        name: '成绩统计',
        component: () => import('@/views/cms/examsScores/scoreStatistics'),
        meta: { title: '成绩统计', icon: 'tree' }
      },
      {
        path: 'edit/:id',
        name: '修改成绩',
        component: () => import('@/views/cms/examsScores/save'),
        meta: { title: '编辑考试成绩信息', noCache: true },
        hidden: true
      }
    ]
  },
  // 选课管理
  {
    path: '/courseSelection',
    component: Layout,
    redirect: '/courseSelection/table',
    name: '选课管理',
    meta: { title: '选课管理', icon: 'example' },
    children: [
      {
        path: 'table',
        name: '选课管理',
        component: () => import('@/views/cms/courseSelection/list'),
        meta: { title: '选课管理', icon: 'table' }
      },
      {
        path: 'save',
        name: '添加选课',
        component: () => import('@/views/cms/courseSelection/save'),
        meta: { title: '添加选课', icon: 'tree' }
      },
      {
        path: 'edit/:id',
        name: '修改选课',
        component: () => import('@/views/cms/courseSelection/save'),
        meta: { title: '编辑选课信息', noCache: true },
        hidden: true
      }
    ]
  },
  // 成绩查询
  {
    path: '/queryScore',
    component: Layout,
    redirect: '/queryScore/find',
    name: '成绩查询',
    meta: { title: '成绩查询', icon: 'example' },
    children: [
      {
        path: 'find',
        name: '成绩查询',
        component: () => import('@/views/cms/studentClient/queryScore'),
        meta: { title: '成绩查询', icon: 'tree' }
      },
    ]
  },
  // 学生选课
  {
    path: '/selectCourse',
    component: Layout,
    redirect: '/selectCourse/select',
    name: '学生选课',
    meta: { title: '学生选课', icon: 'example' },
    children: [
      {
        path: 'select',
        name: '学生选课',
        component: () => import('@/views/cms/studentClient/selectCourse'),
        meta: { title: '学生选课', icon: 'tree' }
      },
    ]
  },
  // 权限
  {
    path: '/acl',
    component: Layout,
    redirect: '/acl/user/list',
    name: '权限管理',
    meta: { title: '权限管理', icon: 'chart' },
    children: [
      {
        path: 'user/list',
        name: '用户管理',
        component: () => import('@/views/acl/user/list'),
        meta: { title: '用户管理' }
      },
      {
        path: 'role/list',
        name: '角色管理',
        component: () => import('@/views/acl/role/list'),
        meta: { title: '角色管理' }
      },
      {
        path: 'role/form',
        name: '角色添加',
        component: () => import('@/views/acl/role/form'),
        meta: { title: '角色添加' },
        hidden: true
      },
      {
        path: 'role/update/:id',
        name: '角色修改',
        component: () => import('@/views/acl/role/form'),
        meta: { title: '角色修改' },
        hidden: true
      },
      {
        path: 'role/distribution/:id',
        name: '角色权限',
        component: () => import('@/views/acl/role/roleForm'),
        meta: { title: '角色权限' },
        hidden: true
      },
      {
        path: 'menu/list',
        name: '菜单管理',
        component: () => import('@/views/acl/menu/list'),
        meta: { title: '菜单管理' }
      },
      {
        path: 'user/add',
        name: '用户添加',
        component: () => import('@/views/acl/user/form'),
        meta: { title: '用户添加' },
        hidden: true
      },
      {
        path: 'user/update/:id',
        name: '用户修改',
        component: () => import('@/views/acl/user/form'),
        meta: { title: '用户修改' },
        hidden: true
      },
      {
        path: 'user/role/:id',
        name: '用户角色',
        component: () => import('@/views/acl/user/roleForm'),
        meta: { title: '用户角色' },
        hidden: true
      }

    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// export default new Router({
//   // mode: 'history', //后端支持可开
//   scrollBehavior: () => ({ y: 0 }),
//   routes: constantRouterMap
// })

export default router
